﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class Main : MonoBehaviour
{
    // Start is called before the first frame update
    void Start()
    {
        TestManager.Instance.TestLog();
        TestManager2.Instance.TestLog();

        TestAutoManeger.Instance.TestLog();

        //破坏单例模式的唯一性，我们自己能够去mew对应的单例模式类对象 不安全
        //TestManager t = new TestManager();
        //BaseManager<TestManager> t2 = new BaseManager<TestManager>();

        //print(UIManager.Instance.GetLayerFather(E_UILayer.Bottom).name);

        //同一帧调用显示某一个面板
        UIManager.Instance.ShowPanel<BeginPanel>(E_UILayer.Top, (panel) =>
        {
            print("第一次显示");
        });

        UIManager.Instance.HidePanel<BeginPanel>();

        UIManager.Instance.ShowPanel<BeginPanel>(E_UILayer.Top, (panel) =>
        {
            print("第二次显示");
        });


        UIManager.Instance.GetPanel<BeginPanel>((panel) =>
        {
            print("获取面板后想要处理的逻辑");
        });

    }

    // Update is called once per frame
    void Update()
    {
        if (Input.GetKeyDown(KeyCode.E))
        {
            Test6Manager.Instance.ICanUpdate();
        }

        if (Input.GetKeyUp(KeyCode.E))
        {
            Test6Manager.Instance.ICanStopUpdate();
        }

        #region 缓存池测试
        if (Input.GetMouseButtonDown(0))
        {
            PoolManager.Instance.GetObj("Test/Cube");
        }
        if (Input.GetMouseButtonDown(1))
        {
            PoolManager.Instance.GetObj("Test/Sphere");
        }
        #endregion

        if (Input.GetKeyDown(KeyCode.S))
        {
            UIManager.Instance.ShowPanel<BeginPanel>(E_UILayer.Bottom, (panel) =>
            {
                panel.TestFun();
            });
        }

        if (Input.GetKeyDown(KeyCode.H))
        {
            UIManager.Instance.HidePanel<BeginPanel>();
        }
    }
}
